# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:ios)

platform :ios do
  #   before_all do  
  #   # ENV["SLACK_URL"] = "https://hooks.slack.com/services/..."  
  #  # cocoapods  
   
  # end  

  lane(:snappy) do |options|
  snapshot(
    project: 'Entrance.xcodeproj',
    scheme: 'SreenshotTests',
    devices: ['iPhone 6s', 'iPhone 6s Plus', 'iPhone 7', 'iPhone 7 Plus'],
    output_simulator_logs: true,
    clear_previous_screenshots: true
  )
  end
  
  desc "Deploy a new version to the App Store"
  lane :appstore do
    # match(type: "appstore")
    # snapshot
    gym(scheme: "Entrance") # Build your app - more options available
    deliver(force: true)
    # frameit
  end

  desc "Run all iOS tests on an iPad"
  lane :test do
  xcodebuild(
    build: true,
    test: true,
    destination: "OS=9.1,name=iPad Air"
  )
  end

  # lane :tests do
  # run_tests(workspace: "Entrance.xcworkspace",
  #           devices: ["iPhone 7s", "iPad Air"]
  #           scheme: "Entrance")
  # end

  lane :beta do
  get_certificates           # invokes cert
  get_provisioning_profile   # invokes sigh
  build_app(scheme: "Entrance",
            workspace: "Entrance.xcworkspace",
            include_bitcode: true)
  end


  lane :upload_firim do
         #sigh(adhoc: true)#申请adhoc证书
         increment_build_number_in_plist(target: [target_name])
         increment_version_number_in_plist(
                  target: [target_name],
                  version_number: '7.1.3'
         )
         gym(#gym用于编译ipa
                  output_directory: './firim',
                  export_options: {
                           method: "ad-hoc", #默认,可以不指定
                           thinning: "<none>"
                  }
         )
         #cc3f09fbded7aa17eb13c332e3b28908
         firim(firim_api_token: [firim_api_token]) #上传ipa到fir.im服务器
	end
end
